﻿Imports System.Data.SqlClient
Public Class ProductExpire
    Dim cmd As New SqlCommand
    Public Sub refreshdata()
        grdproduct.Rows.Clear()
            Dim d As Date = Now
            cmd.Connection = cn
        cmd.CommandText = "SELECT ProID ,ProName , PriceIN ,PriceOut ,Qty ,Madedate ,Expiredate ,Description from tblproduct WHERE DateDiff( day, GetDate() ,Expiredate ) <= '" & txtexpire.Text & "'"
        'cmd.Parameters.Add("@date", SqlDbType.Date).Value = d
            Dim rd = cmd.ExecuteReader
            While rd.Read = True
            Me.grdproduct.Rows.Add(rd(0), rd(1), rd(2), rd(3), rd(4), rd(5), rd(6), rd(7))
            End While
            rd.Close()

    End Sub

    Private Sub ProductExpire_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        condb()
        refreshdata()
    End Sub

    Private Sub txtexpire_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtexpire.TextChanged
        condb()
        refreshdata()
    End Sub
End Class